import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.TextField;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

public class Test {
	public static void main(String args[]) {
		while (true) {
			PointerInfo info = MouseInfo.getPointerInfo();
			Point p = info.getLocation();
			System.out.println(p.x+","+p.y);
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			
		}

		// new myFrame();
	}
}

class myFrame extends Frame {
	TextField tf1, tf2;

	public myFrame() {
		tf1 = new TextField(5);
		tf2 = new TextField(5);
		add(tf1);
		add(tf2);
		setLayout(new FlowLayout());
		setBounds(100, 100, 400, 300);
		addMouseMotionListener(new MouseMotionAdapter() {// 鼠标移动事件的侦听器
			public void mouseMoved(MouseEvent e) {// 鼠标按键在组件上移动（无按键按下）时调用。
				tf1.setText(e.getX() + "");
				tf2.setText(e.getY() + "");
			}
		});
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
		setVisible(true);
	}
}